﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>用户登录</title>
    <link href="~/Scripts/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Scripts/bootstrap-3.3.7/css/bootstrap-theme.min.css" rel="stylesheet" />
    <link href="~/Content/Login.css" rel="stylesheet" />
    <link href="~/Scripts/toastr-master/toastr.min.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-3.2.1.min.js"></script>
    <script src="~/Scripts/bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <script src="~/Scripts/toastr-master/toastr.min.js"></script>
</head>
<body>
    <div>
        <div class="main-bg">
            <img src="~/image/bg.png" />
        </div>
        <div class="main-count">
            <div class="main-top">
                <img src="~/image/logo.png" />
            </div>
            <div class="main-middle">
                <div class="main-middle-count">AGV智能调度系统</div>
            </div>
            <div class="main-centre ">
                <div class="main-centre-count" >
                    <form method="POST" role="form" id="form-test" >
                        <div class="form-group main-group">
                            <div class="input-group">
                                <span class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-user"></span></span>
                                <input type="text" id="UserName" name="UserName" class="form-control" placeholder="请输入账号" aria-describedby="basic-addon1">
                            </div>
                        </div>
                        <div class="form-group main-group">
                            <div class="input-group">
                                <span class="input-group-addon" id="basic-addon2"><span class="glyphicon glyphicon-lock"></span></span>
                                <input type="password" id="Password" name="Password" class="form-control" placeholder="请输入密码" aria-describedby="basic-addon2">
                            </div>
                        </div>
                        <div class="form-group main-form">
                            <div class="input-group inut-main">
                                <button id="btn-test"  style="background-color: #ffba19;color:white;font-weight:bold" class="btn  btn-block" type="button">登&nbsp;录</button>
                            </div>
                        </div>
                        <div class="main-bottom">
                            <p>
                                Copyright &copy;
                                <script>document.write((new Date()).getFullYear());</script>  Galaxis
                            </p>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <script>
        $(function () {

            $('#btn-test').click(function () {
                if ($('#UserName').val() == "" || $('#Password').val() == "") {
                    toastr.error('账号密码不能为空！');
                    return;
                }
                $.ajax({
                    type: 'post',
                    url: '/api/agvlogin/LoginUser',
                    contentType: 'application/json',
                    data: JSON.stringify({ "userName": $('#UserName').val(), "userPassword": $('#Password').val() }),
                    datatype: 'json',
                    success: function (res) {
                        if (res.Success) {
                            toastr.info(res.Message);
                            setTimeout(function () {
                                window.location.href = "/Home/Main";
                            }, 100);
                        }
                        else {
                            toastr.error(res.Message);
                        }
                    },
                    error: function (e) {
                        toastr.error(e.responseText);
                    }
                });
            });
        });

        document.body.addEventListener('keyup', function (e) {
            if (e.keyCode == '13') {
                $('#btn-test').trigger("click");
            }
        });

    </script>
</body>
</html>
